package Controlers;

import java.awt.Graphics;
import java.awt.Image;
import javax.swing.ImageIcon;
import Objects.Shooter;

public class LifeBarControler {

	private Image icon100;
	private Image icon90;
	private Image icon80;
	private Image icon70;
	private Image icon60;
	private Image icon50;
	private Image icon40;
	private Image icon30;
	private Image icon20;
	private Image icon10;
	private Image icon0;
	private Image icon;
	
	public LifeBarControler() {
		icon100 = new ImageIcon(getClass().getResource("/Sprites/life100.png")).getImage();
		icon90 = new ImageIcon(getClass().getResource("/Sprites/life90.png")).getImage();
		icon80 = new ImageIcon(getClass().getResource("/Sprites/life80.png")).getImage();
		icon70 = new ImageIcon(getClass().getResource("/Sprites/life70.png")).getImage();
		icon60 = new ImageIcon(getClass().getResource("/Sprites/life60.png")).getImage();
		icon50 = new ImageIcon(getClass().getResource("/Sprites/life50.png")).getImage();
		icon40 = new ImageIcon(getClass().getResource("/Sprites/life40.png")).getImage();
		icon30 = new ImageIcon(getClass().getResource("/Sprites/life30.png")).getImage();
		icon20 = new ImageIcon(getClass().getResource("/Sprites/life20.png")).getImage();
		icon10 = new ImageIcon(getClass().getResource("/Sprites/life10.png")).getImage();
		icon0 = new ImageIcon(getClass().getResource("/Sprites/life0.png")).getImage();
	}
	
	public void draw(Graphics g, Shooter shooter) {
		
		if(shooter.getLifeBar() < 10) {
			icon = icon0;
		}
		else {
			if(shooter.getLifeBar() < 20) {
				icon = icon10;
			}
			else {
				if(shooter.getLifeBar() < 30) {
					icon = icon20;
				}
				else {
					if(shooter.getLifeBar() < 40) {
						icon = icon30;
					}
					else {
						if(shooter.getLifeBar() < 50) {
							icon = icon40;
						}
						else {
							if(shooter.getLifeBar() < 60) {
								icon = icon50;
							}
							else {
								if(shooter.getLifeBar() < 70) {
									icon = icon60;
								}
								else {
									if(shooter.getLifeBar() < 80) {
										icon = icon70;
									}
									else {
										if(shooter.getLifeBar() < 90) {
											icon = icon80;
										}
										else {
											if(shooter.getLifeBar() < 100) {
												icon = icon90;
											}
											else {
												icon = icon100;
											}
										}										
									}
								}
							}
						}
					}
				}
			}
		}
		g.drawImage(icon, 0, 600, null); 
	}
}
